<?php

namespace app\controller;

use app\service\TaskRepairReportService;
use support\Request;
use support\Response;

/**
 * 任务返修报表所需接口
 */
class TaskRepairReportController
{
    private TaskRepairReportService $taskRepairReportService;

    public function __construct()
    {
        $this->taskRepairReportService = TaskRepairReportService::getInstance();
    }

    /**
     * @title 获取任务返修情况
     */
    public function getTaskRepairList(Request $request)
    {
        $param = $request->post()['param'] ?? [];
        $projectIds = $param['project_ids'] ?? [];
        $stepCategoryIds = $param['step_category_ids'] ?? [];
        $timeScope = [];
        if (isset($param['start_time']) && isset($param['end_time'])) {
            $timeScope = [$param['start_time'], $param['end_time']];
        }
        $page = $param['page'] ?? [];
        $queryType = $param['query_type'] ?? 'default';
        $response = $this->taskRepairReportService->getTaskRepairList($projectIds, $stepCategoryIds, $timeScope, $page, $queryType);
        return json(success_response('success', $response));
    }


}